{{ template "header" . }}
	<div class="layui-container index">
		<div class="space-left">
			{{ template "user-nav-left" . }}
		</div>
		<div class="space-right">
			<!-- 个人信息 -->
			<div class="space-box space-userinfo">
				<div class="space-title">
					修改密码
				</div>
				<div class="space-info">
					<form method="post" class="layui-form">
						<div class="layui-form-item">
							<label class="layui-form-label">原密码</label>
							<div class="layui-input-block">
								<input type="password" name="password" required  lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">新密码</label>
							<div class="layui-input-block">
								<input type="password" name="new_password" required  lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">确认密码</label>
							<div class="layui-input-block">
								<input type="password" name="re_password" required  lay-verify="required" placeholder="请确认新密码" autocomplete="off" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn" type="button" lay-submit lay-filter="submit">确认更新</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
{{ template "footer" . }}
<script>
	//Demo
	layui.use(['form'], function(){
		var form = layui.form;

		//监听提交
		form.on('submit(submit)', function(data){
			if (data.field.new_password != data.field.re_password) {
				layer.msg("两次密码输入不一致")
				return
			}
			$.post('/password' , data.field , (data) => {
				if (data.status) {
					layer.msg(data.msg)
					return;
				}
				layer.msg(data.msg)
				setTimeout(function(){
					window.location.href = "/login";
				} , 1500)
			} , 'json');
			return false;
		});
	});
</script>